package com.model.defaults.tabsheet;

import java.util.Map;

import org.hibernate.Session;

import com.core.GlobalConstants;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.TabSheetItem;
import com.model.UserContextName;


public class ModelDefaultTabsheetRole {

	public static void createTabsheetItemsRoleInfo ( Session session,
	                                                 Map <String, UserContextName> userContexts ) {

		/*
		 * BrowseAdministration
		 */

		TabSheetItem pojo = null;
		UserContextName contextName_1 = null;
		ActionScript actionScript = null;
		KeyValue actionScriptParam = null;


		actionScript = new ActionScript();
		actionScriptParam = new KeyValue("p3", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("t1", "selectedTab=1");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptText("%s?{p3}&{t1}", GlobalConstants.SERVLET_ROLEINFO);
		actionScript.setActionScriptType("servlet");

		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_ROLEINFO);
		pojo = new TabSheetItem();
		pojo.setName("Description");
		pojo.setCaption("Description");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setJspNameInContext("details/tabRoleInfo.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_ROLEINFO);
		pojo.setIsDefault(true);
		pojo.setActionScript(actionScript);
		session.save(pojo);


		actionScript = new ActionScript();

		actionScriptParam = new KeyValue("p3", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("t1", "selectedTab=2");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptText("%s?{p3}&{t1}", GlobalConstants.SERVLET_ROLEINFO);
		actionScript.setActionScriptType("servlet");

		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_ROLEINFO);
		pojo = new TabSheetItem();
		pojo.setName("Permissions");
		pojo.setCaption("Permissions");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setJspNameInContext("details/tabRoleActivity.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_ROLEINFO);
		pojo.setActionScript(actionScript);
		session.save(pojo);

	}
}
